package com.sjzl.dwr;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import com.sjzl.dao.impl.DaoImpl;
import com.sjzl.entity.User;

/**
 * 
 * @author 莫伯先
 *
 */
@Service
public class CheckRegister {
	
	/**
	 * 注册检查
	 * @param account
	 * @return
	 */
	public String checkRegister(String account) {
		ApplicationContext ac = new ClassPathXmlApplicationContext(
				new String[] { "applicationContext.xml" });
		DaoImpl dao = (DaoImpl) ac.getBean("daoImpl");
		String name = "1";
		String hql = "from User";
		List<User> list = dao.list(hql);
		for (User user : list) {
			if (account.trim().equals(user.getAccount())) {
				name = "0";
			}

		}
		return name;
	}

}
